﻿Imports ACompany.OrderProcessing.Infrastructure

Public Module ControllerHelpers

    <System.Runtime.CompilerServices.Extension()> _
    Public Sub AddRuleViolations(ByVal modelState As ModelStateDictionary, ByVal errors As IEnumerable(Of BrokenRule))

        For Each brokenRule As BrokenRule In errors
            modelState.AddModelError(brokenRule.RelatesToProperty, brokenRule.Rule)
        Next

    End Sub

    <System.Runtime.CompilerServices.Extension()> _
    Public Function ConvertStringToDouble(ByVal stringToCheck As String) As Double

        If IsNumeric(stringToCheck) Then
            Return CDbl(stringToCheck)
        Else
            Return 0
        End If

    End Function

End Module
